<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
</head>

<body>
  <div id="box" draggable="true" style="width: 100px; height: 100px; background-color: gold; padding: 10px;">
    我是一个div
  </div>

  <script>
    function throttle(fn, delay = 100) {
      let timer = 0;
      return function () {
        if (timer) return;
        timer = setTimeout(() => {
          fn.apply(this, arguments)
          timer = 0;
        }, delay)
      }
    }

    const box = document.getElementById("box");
    box.addEventListener("drag", throttle((e) => {
      console.log("鼠标位置:", e.offsetX, e.offsetY);
    }, 1000))
  </script>
</body>

</html>